﻿using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NLog;

namespace WebForm
{
    public partial class _Default : Page
    {
        private readonly ILogger _logger= LogManager.GetCurrentClassLogger();


        protected void Page_Load(object sender, EventArgs e)
        {
            var g = Guid.NewGuid().ToString("N");

            Task.Run(() =>
            {
             
                Thread.Sleep(180000);
                _logger.Warn(
                    $"Task-{g}:CurrentThreadId:{Thread.CurrentThread.ManagedThreadId},Timestamp:{GetTimestamp(DateTime.Now)}");
            });

         


            _logger.Warn(
                $"Page-{g}:CurrentThreadId:{Thread.CurrentThread.ManagedThreadId},Timestamp:{GetTimestamp(DateTime.Now)}");


            Response.Write("ok");

        }


        public static double GetTimestamp(DateTime d)
        {
            TimeSpan ts = d.ToUniversalTime() - new DateTime(1970, 1, 1);
            return ts.TotalMilliseconds;     //精确到毫秒
        }
    }
}